home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].zip / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].adf / A68K_Beispiele / boing.asm < prev    next >
Assembly Source File  |  1989-07-02  |  7KB  |  249 lines

  1. ****************************
  2. * This is another one of   *
  3. * those useless 'Boing'    *
  4. * type things.             *
  5. *                          *
  6. * written by:              *
  7. * E. Lenz                  *
  8. * Johann-Fichte-Strasse 11 *
  9. * 8 Munich 40              *
  10. * Germany                  *
  11. *                          *
  12. ****************************
  13.  
  14. _AbsExecBase      equ 4
  15.  
  16. **** exec *****
  17.  
  18. _LVOForbid       equ -$84
  19. _LVOPermit       equ -$8a
  20. _LVOAllocMem     equ -$c6
  21. _LVOFreeMem      equ -$d2
  22. _LVOGetMsg       equ -$174
  23. _LVOReplyMsg     equ -$17a
  24. _LVOWaitPort     equ -$180
  25. _LVOCloseLibrary equ -$19e
  26. _LVOOpenLibrary  equ -$228
  27.  
  28. **** Graphics ****
  29.  
  30. _LVOGetSprite    equ -$198
  31. _LVOFreeSprite   equ -$19e
  32. _LVOChangeSprite equ -$1a4
  33.  
  34. **** Dos ***
  35.  
  36. _LVODelay        equ -$c6
  37.  
  38. pr_MsgPort       equ $5c
  39. pr_CLI           equ $ac
  40. ThisTask         equ $114
  41. VBlankFrequency  equ $212
  42.  
  43.       movea.l _AbsExecBase,a6     test if WB or CLI
  44.       movea.l ThisTask(a6),a0
  45.       moveq   #0,d0
  46.       tst.l   pr_CLI(a0)
  47.       bne.s   isCLI
  48.  
  49.       lea     pr_MsgPort(a0),a0   for WB get WB Message
  50.       jsr     _LVOWaitPort(a6)
  51.       jsr     _LVOGetMsg(a6)
  52.  
  53. isCLI move.l  d0,-(a7)
  54.  
  55.       cmpi.b  #60,VBlankFrequency(a6) test if PAL or NTSC
  56.       beq.s   isNTS
  57.       move.w  #242,tryy+2
  58.       move.w  #242,triy+2
  59.  
  60. isNTS move.l  #Imend-SimpleSprite,d0
  61.       moveq   #2,d1               chip memory
  62.       jsr     _LVOAllocMem(a6)
  63.       move.l  d0,sprite1
  64.       beq.s   Gexit
  65.  
  66.       move.l  d0,d1
  67.       add.l   #Site-SimpleSprite,d1
  68.       move.l  d1,sprite2
  69.  
  70.       lea     SimpleSprite(pc),a0
  71.       movea.l d0,a1
  72.       move.l  #Imend-SimpleSprite-1,d0
  73. trans move.b  (a0)+,(a1)+
  74.       dbra    d0,trans
  75.  
  76.       lea     DosName(pc),a1      open dos library
  77.       moveq   #0,d0
  78.       jsr     _LVOOpenLibrary(a6)
  79.       movea.l d0,a5
  80.       tst.l   d0
  81.       beq.s   Gexit
  82.  
  83.       lea     GfxName(pc),a1      open graphics library
  84.       moveq   #0,d0
  85.       jsr     _LVOOpenLibrary(a6)
  86.       movea.l d0,a4
  87. Gexit beq     exit
  88.  
  89.       movea.l d0,a6
  90.       moveq   #-1,d0               set sprite Nr. 1
  91.       movea.l sprite1(pc),a0
  92.       jsr     _LVOGetSprite(a6)
  93.       move.w  d0,No1
  94.  
  95.       moveq   #-1,d0               set sprite Nr. 2
  96.       movea.l sprite2(pc),a0
  97.       jsr     _LVOGetSprite(a6)
  98.       move.w  d0,No2
  99.  
  100.       moveq   #8,d3
  101.       moveq   #5,d4
  102.       moveq   #-8,d5
  103.       moveq   #6,d6
  104.  
  105. loop  movea.l a5,a6               wait a while
  106.       moveq   #1,d1
  107.       jsr     _LVODelay(a6)
  108.       movea.l a4,a6
  109.       suba.l  a0,a0               no ViewPort
  110.       movea.l sprite1(pc),a1
  111.       lea     Image-SimpleSprite(a1),a2
  112.       add.w   d3,6(a1)            increment X-pos
  113.       add.w   d4,8(a1)            increment Y-Pos
  114.       jsr     _LVOChangeSprite(a6) set sprite
  115.  
  116.       suba.l  a0,a0               no ViewPort
  117.       movea.l sprite2(pc),a1
  118.       lea     Imag-Site(a1),a2    pointer to sprite data
  119.       add.w   d5,6(a1)            increment X-pos
  120.       add.w   d6,8(a1)            increment Y-Pos
  121.       jsr     _LVOChangeSprite(a6) set sprite
  122.  
  123.       btst    #6,$bfe001          mouse clicked?
  124.       beq.s   exit
  125.  
  126.       movea.l sprite1(pc),a1      check boundries
  127.       cmpi.w  #300,6(a1)
  128.       bge.s   negx
  129.       tst.w   6(a1)
  130.       bpl.s   tryy
  131. negx  neg.w   d3
  132. tryy  cmpi.w  #184,8(a1)
  133.       bge.s   negy
  134.       tst.w   8(a1)
  135.       bpl.s   next
  136. negy  neg.w   d4
  137.  
  138. next  movea.l sprite2(pc),a1
  139.       cmpi.w  #300,6(a1)
  140.       bge.s   notx
  141.       tst.w   6(a1)
  142.       bpl.s   triy
  143. notx  neg.w   d5
  144. triy  cmpi.w  #184,8(a1)
  145.       bge.s   noty
  146.       tst.w   8(a1)
  147.       bpl.s   Glop
  148. noty  neg.w   d6
  149. Glop  bra     loop
  150.  
  151. exit  move.l  sprite1(pc),d0
  152.       beq.s   nosp1
  153.       movea.l _AbsExecBase,a6
  154.       movea.l d0,a1
  155.       move.l  #Imend-SimpleSprite,d0
  156.       jsr     _LVOFreeMem(a6)
  157.  
  158.       movea.l a4,a6               remove sprite
  159.       move.w  No1(pc),d0
  160.       jsr     _LVOFreeSprite(a6)
  161.  
  162. nosp1 move.l  sprite2(pc),d0      remove sprite
  163.       beq.s   nosp2
  164.       move.w  No2(pc),d0
  165.       jsr     _LVOFreeSprite(a6)
  166.  
  167. nosp2 movea.l _AbsExecBase,a6
  168.       move.l  (a7)+,d0
  169.       beq.s   NoBen
  170.       jsr     _LVOForbid(a6)      reply to WB
  171.       movea.l d0,a1
  172.       jsr     _LVOReplyMsg(a6)
  173.       jsr     _LVOPermit(a6)
  174.  
  175. NoBen move.l  a4,d1               close graphics library
  176.       beq.s   noGfx
  177.       movea.l d1,a1
  178.       jsr     _LVOCloseLibrary(a6)
  179.  
  180. noGfx move.l  a5,d1
  181.       beq.s   noDos
  182.       movea.l d1,a1
  183.       jsr     _LVOCloseLibrary(a6)
  184.  
  185. noDos moveq   #0,d0               no error
  186.       rts
  187.  
  188.  
  189. No1      dc.w 0
  190. sprite1  dc.l 0
  191. No2      dc.w 0
  192. sprite2  dc.l 0
  193.  
  194. GfxName dc.b  'graphics.library',0
  195.         even
  196.  
  197. DosName dc.b 'dos.library',0
  198.         even
  199.  
  200. * SimpleSprite structures
  201.  
  202. SimpleSprite dc.w  0,0   pointer to image
  203.       dc.w 16,0,0        height, X- aund Y-pos
  204.       dc.w 0             sprite number
  205.  
  206. Image dc.l  0            sprite data
  207.       dc.l  %00000111111000000000000000000000
  208.       dc.l  %00011100001110000000000000000000
  209.       dc.l  %00111100001111000000000000000000
  210.       dc.l  %01111100001111100000000000000000
  211.       dc.l  %01000011110000100000000000000000
  212.       dc.l  %10000011110000010000000000000000
  213.       dc.l  %10000011110000010000000000000000
  214.       dc.l  %11111100001111110000000000000000
  215.       dc.l  %11111100001111110000000000000000
  216.       dc.l  %11111100001111110000000000000000
  217.       dc.l  %10000011110000010000000000000000
  218.       dc.l  %01000011110000100000000000000000
  219.       dc.l  %01000011110000100000000000000000
  220.       dc.l  %00111100001111100000000000000000
  221.       dc.l  %00011100001110000000000000000000
  222.       dc.l  %00000111111000000000000000000000
  223.       dc.l  0
  224.  
  225. Site  dc.w  0,0        pointer to image
  226.       dc.w 16,300,0    height, X- aund Y-pos
  227.       dc.w 0           sprite number
  228.  
  229. Imag  dc.l  0            sprite data
  230.       dc.l  %00000111111000000000011111100000
  231.       dc.l  %00011100001110000001110000111000
  232.       dc.l  %00111100001111000011110000111100
  233.       dc.l  %01111100001111100111110000111110
  234.       dc.l  %01000011110000100100001111000010
  235.       dc.l  %10000011110000011000001111000001
  236.       dc.l  %10000011110000011000001111000001
  237.       dc.l  %11111100001111111111110000111111
  238.       dc.l  %11111100001111111111110000111111
  239.       dc.l  %11111100001111111111110000111111
  240.       dc.l  %10000011110000011000001111000001
  241.       dc.l  %01000011110000100100001111000010
  242.       dc.l  %01000011110000100100001111000010
  243.       dc.l  %00111100001111100011110000111110
  244.       dc.l  %00011100001110000001110000111000
  245.       dc.l  %00000111111000000000011111100000
  246.       dc.l  0
  247. Imend:
  248.       end
  249.